package com.northpool.stpclient.demo;

import com.northpool.resources.Constants;
import com.northpool.resources.datasource.IDataSource;
import com.northpool.resources.datasource.db.DbDataSource;
import com.northpool.stpclient.StpClient;
import com.northpool.stpclient.bean.BaseResponse;
import com.northpool.stpclient.bean.overlay.OverlapCheckPlan;
import com.northpool.stpclient.modules.geoprocess.overlay.IOverlayOperator;

import java.io.UnsupportedEncodingException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;

public class OverlapCheckDemo {
    // stpserver访问地址
    public static final String host = "http://127.0.0.1:8088/stpserver";
    // 构建客户端
    public static StpClient client = new StpClient(host);

    public static void main(String[] args) throws UnsupportedEncodingException, ExecutionException, InterruptedException {
        IOverlayOperator overlayOperator = client.overlayOperator();
        OverlapCheckPlan plan = new OverlapCheckPlan();
        plan.setDataSourceId("shape_select"); // stpserver config/datasource.json 配置文件中配置，暂不支持动态数据源
        plan.setTableName("dltbcut_cut_osm_building_cl");
        plan.setTargetTableName("dltbcut_cut_osm_building_cl_shp_lapcheck"); // stpserver config/application-proc.yml 中配置的targetDataSource
        plan.setTargetLevel(14); //计算时使用的格网层级

        CompletableFuture<BaseResponse> result = overlayOperator.startOverlayCheckAsync(plan);
        BaseResponse baseResponse = result.get();

        System.out.println(baseResponse.getMessage());

    }
}
